package com.wlps.service.function;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wlps.bo.QueryComposeBo;

import java.util.List;

public abstract class TemplateQuery<T> {

    public abstract LambdaQueryWrapper<T> changeOrderColumn(QueryComposeBo queryComposeBo);

    public abstract SFunction<T, ?> getFinishDatColumn();


    public List<T> queryOrdersByCompose(QueryComposeBo query, IService<T> iService){
        LambdaQueryWrapper<T> wrapper = changeOrderColumn(query);
        wrapper.ge(query.getCreateTime() != null,getFinishDatColumn() , query.getCreateTime())
                .lt(query.getCreateTime() != null, getFinishDatColumn(), query.getFinishTime());
        return iService.list(wrapper);

    }
}
